package o;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import com.huawei.appgallery.serverreqkit.api.bean.ResponseBean;
import com.huawei.appgallery.serverreqkit.api.listener.IServerCallBack;
import com.huawei.appmarket.service.deamon.bean.DownloadResultResponse;
import o.avx.a;
import o.ewm.n;

public class dvn implements IServerCallBack {

    static class d implements ServiceConnection {
        private dvk ˋ;
        private Context ˎ;

        private d(dvk o_dvk, Context context) {
            this.ˋ = o_dvk;
            this.ˎ = context;
        }

        public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
            avx ˎ = a.ˎ(iBinder);
            try {
                Logger.ˎ("DownloadRCallBack", "set app info to pps");
                ˎ.ॱ(this.ˋ.ॱ(), 1, this.ˋ.ˎ(), this.ˋ.ˊ());
            } catch (RemoteException e) {
                Logger.e("DownloadRCallBack", "catch a RemoteException");
            } catch (Exception e2) {
                Logger.e("DownloadRCallBack", "catch a Exception");
            }
            this.ˎ.unbindService(this);
        }

        public void onServiceDisconnected(ComponentName componentName) {
        }
    }

    public void notifyResult(BaseRequest o_cvu, ResponseBean responseBean) {
        DownloadResultResponse downloadResultResponse = (DownloadResultResponse) responseBean;
        Logger.ˎ("DownloadRCallBack", "DownloadResultResponse rtnCode_:" + downloadResultResponse.getRtnCode_());
        switch (downloadResultResponse.getRtnCode_()) {
            case 4:
                ˏ(n.ʿᐝ);
                return;
            case 5:
                ˏ(n.ˈˊ);
                return;
            default:
                return;
        }
    }

    private void ˏ(int i) {
        if (epv.ᐝ(ContentManager.getInstant().getContext()) || !cep.ˏ()) {
            evk.ˏ(ContentManager.getInstant().getContext(), i, 0).ˋ();
        }
    }

    public void prePostResult(BaseRequest o_cvu, ResponseBean responseBean) {
        dvk o_dvk = (dvk) o_cvu;
        if (String.valueOf(1).equals(o_dvk.ˋ())) {
            Context ˋ = ContentManager.getInstant().getContext();
            Intent intent = new Intent("com.huawei.android.hms.CHANNEL_SERVICE");
            intent.setPackage("com.huawei.hwid");
            ˋ.bindService(intent, new d(o_dvk, ˋ), 1);
        }
    }
}
